import instance from '@/utils/http'
import { getStorage } from '@/utils/storage'

export class Evaluation {
  constructor() {}

  async submitScore({ score, title, uid }) {
    const result = await instance.post('/evaluation/add', {
      score,
      title,
      uid,
    })

    console.log(result)

    return result
  }

  async getEvaluations() {
    const uid = getStorage('uid')
    const result = await instance.get(`/evaluation?uid=${uid}`)
    return result.data
  }

  async getTodayEvaluation({ title }) {
    const uid = getStorage('uid')
    const result = await instance.post('/evaluation/query', {
      title,
      uid,
    })
    return result
  }
}
